package com.demo.forum.controller;

import com.demo.forum.common.Result;
import com.demo.forum.model.exception.ApplicationException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "测试类相关的接口")
@RestController
@RequestMapping("/test")

public class TestController {
    @ApiOperation("测试接口1")
    @GetMapping("/hello")
    public Result hello(@ApiParam("姓名") String name){
        return Result.success("hello! "+ name);
    }

    @GetMapping("/Exception")
    @ApiOperation("测试接口2")

    public String exception() throws Exception {
        throw new Exception("11111 Exception");
    }

    @GetMapping("/AppException")
    @ApiOperation("测试接口3")
    public String AppException (){
        throw new ApplicationException("22222  AppException " );
    }
}
